package com.example.demo.singleton;

/**
 * @author void
 * @date 2022/2/17 16:45
 * @desc 双检锁/双重校验锁 + volatile关键字
 */
public class Singleton7 {
    
    private static volatile Singleton7 instance = null;

    public Singleton7() {
    }
    
    public static Singleton7 getInstance(){
        if(instance==null){
            synchronized (Singleton7.class){
                if(instance==null){
                    instance = new Singleton7();
                }
            }
        }
        return instance;
    }
}
